// ignore_for_file: always_specify_types, prefer_const_constructors

import 'package:flutter/material.dart';
import 'package:medical_pro_flutter/components/illcase/ShowCasePage.dart';
import 'package:medical_pro_flutter/components/illcase/ShowPushCasePage.dart';

import '../components/login/login_page.dart';
import '../components/login/widgets/sign_in.dart';
import '../components/tabs/Tabs.dart';
import '../components/change/ChangeInfo.dart';
import '../components/illcase/CaseFirstPage.dart';
import '../components/illcase/CaseSecondPage.dart';
import '../components/illcase/PostCaseFBPage.dart';
import '../components/list/ExpertList.dart';

final routes = {
  '/': (context, {arguments}) => Tabs(),
  '/login': (context, {arguments}) => LoginPage(),
  '/changeinfo': (context, {arguments}) => ChangeInfoPage(),
  '/inputcase1': (context, {arguments}) => CaseFirstPage(),
  '/inputcase2': (context, {arguments}) => CaseSecondPage(arguments: arguments),
  '/post_case': (context, {arguments}) => PostCaseFBPage(arguments: arguments),
  '/expert_list': (context, {arguments}) => ExpertListPage(),
  '/show_case_page': (context, {arguments}) => ShowCasePage(arguments),
  '/show_push_case_page': (context, {arguments}) => ShowPushCasePage(arguments),
};

var onGenerateRoute = (RouteSettings settings) {
  // 统一处理
  final String? name = settings.name;
  final Function? pageContentBuilder = routes[name];
  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      final Route route = MaterialPageRoute(
          builder: (context) =>
              pageContentBuilder(context, arguments: settings.arguments));
      return route;
    } else {
      final Route route =
          MaterialPageRoute(builder: (context) => pageContentBuilder(context));
      return route;
    }
  }
};
